package service

import (
	"math/rand"
	"rongyy/src/models"
	"strconv"
	"time"
)

type OrderService struct {
	d *models.OrdersModel
}

func (ds *OrderService) Create(req *models.OrdersModel) error {
	if req.Type == "01" {
		req.Status = "pending"
	}
	t := rand.Intn(10000)
	ts := strconv.FormatInt(time.Now().UnixMicro(), 10)
	req.OrderSn = "SN" + ts + strconv.Itoa(t)
	err := req.Create()
	if err != nil {
		return err
	}
	return nil
}

//func (ds *OrderTrackService) QueryTrackOrder(req *models.ReqTrack) ([]models.OrderTrackModel, int64, error) {
//	rm := &models.OrderTrackModel{}
//	data, total, err := rm.QueryTrackOrder(req)
//	if err != nil {
//		return nil, 0, err
//	}
//	return data, total, nil
//}
